package com.example.demo.controller;

import com.example.demo.domain.Result;
import com.example.demo.domain.RoomShceduie;
import com.example.demo.service.RoomShceduieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/room")
public class RoomShceduieController {

    @Autowired
    RoomShceduieService roomShceduieService;

    //查询所有
    @RequestMapping("/findAllRoom")
    public Result findAllRoom() {
        List<RoomShceduie> list = roomShceduieService.findAllRoom();
        return Result.ok(list);
    }

    //删除
    @RequestMapping("/deleteRoom")
    public Result deleteRoom(Integer id) {
        roomShceduieService.deleteRoom(id);
        return Result.ok();
    }

    //修改
    @RequestMapping("/updateRoom")
    public Result updateRoom(@RequestBody RoomShceduie data) {
        System.out.println("接收的数据"+data);
        roomShceduieService.updateRoom(data);
        return Result.ok();
    }

    //添加
    @PostMapping("/addRoom")
    public Result addRoom(@RequestBody RoomShceduie data) {
        System.out.println("接收的数据"+data);
        roomShceduieService.addRoom(data);
        return Result.ok();
    }

    //查询
    @RequestMapping("/findRoom")
    public Result findRoom(@RequestBody RoomShceduie data) {
        System.out.println("接收的数据"+data);
        List<RoomShceduie> list = roomShceduieService.findRoom(data);
        return Result.ok(list);
    }
}
